package cn.fantasy.strategy;

import java.util.HashMap;

/**
 * @author ET
 * @description TODO
 * @date 2023/5/13 12:08
 * @Version V1.0
 */
public class ContextLambda {

    private static GearStrategyLambda gearStrategyLambda1 = param -> {
        System.out.println("param");
    };

    private static GearStrategyLambda gearStrategyLambda2 = param -> {
        System.out.println("param");
    };

    static HashMap<String, GearStrategyLambda> objectObjectHashMap = new HashMap<>();
    static {
        objectObjectHashMap.put("one", gearStrategyLambda1);
        objectObjectHashMap.put("two", gearStrategyLambda2);
    }

    private static GearStrategyLambda getStrategy(String type) {
        if (type == null || type.isEmpty()) {
            throw new IllegalArgumentException("type should not be empty.");
        } else {
            return objectObjectHashMap.get(type);
        }
    };

    public static void main(String[] args) {
        String a = "one";
        getStrategy(a).algorithm(a);
    };
}

